package it.enricod.jcontextfree.model.impl;

import java.util.List;

import com.google.inject.Inject;

import it.enricod.jcontextfree.model.IProgramPM;
import it.enricod.jcontextfree.model.IProgramsLoader;
import it.enricod.jcontextfree.model.IProgramsRegistry;

public class ProgramsRegistry implements IProgramsRegistry {

	private IProgramsLoader programsLoader;
	private List<IProgramPM> programs;

	@Inject
	public ProgramsRegistry(IProgramsLoader programsLoader) {
		this.programsLoader = programsLoader;
	}

	public void load() {
		programs = programsLoader.getPrograms();

	}

	public List<IProgramPM> getPrograms() {
		if (programs == null) {
			load();
		}
		return programs;
	}

	public IProgramPM getWelcomProgram() {
		return programsLoader.getWelcomeProgram();
	}
}
